#!/usr/bin/env python3
# 简单的测试脚本，避免编码问题

from app.core.database import SessionLocal
from app.services.question_service import QuestionService
from app import schemas

def test():
    print("Testing QuestionService...")
    
    db = SessionLocal()
    try:
        service = QuestionService(db)
        config = schemas.TestConfig(grade_id=1, question_count=5, time_limit=30)
        
        print("Calling generate_test_paper...")
        result = service.generate_test_paper(config)
        
        print("SUCCESS!")
        print("Test paper ID:", result.id)
        print("Title:", result.title)
        print("Total score:", result.total_score)
        
        return True
        
    except Exception as e:
        print("ERROR:", str(e))
        import traceback
        traceback.print_exc()
        return False
        
    finally:
        db.close()

if __name__ == "__main__":
    test()